package com.topfun.utils;

/**
 * Created by huangda on 2017-01-18.
 *
 */
@SuppressWarnings("unused")
public enum Code {
    // ===========================================================
    // Constants
    // ===========================================================
    SUCCESS(0, "成功"),
    ERR_DEFAULT(200, "未知错误"),
    ERR_TASK_NOT_IMPLEMENTS(201, "处理功能尚未实现"),
    // 通用
    ERR_UNSUPPORTED_SERVICE(400, "不支持此服务"),
    ERR_INVALID_TOKEN(403, "无效的授权码"),
    ERR_MISS_PARAMETERS(404, "缺少必要的参数"),
    ERR_INVALID_PARAMETERS(405, "参数内容不正确"),
    ERR_SERVICE_BUSY(500, "服务正忙，请稍后重试"),

    ERR_AUTH_FROM_THIRD_FAIL(1004, "无法验证账户登录信息，请重试"),
    ERR_AUTH_FROM_THIRD_RETURN_ERROR(1005, "验证账户登录时出错，请重试"),
    ERR_GET_USER_FROM_THIRD_FAIL(1006, "无法获取用户信息，请重试"),
    ERR_GET_USER_FROM_THIRD_RETURN_ERROR(1007, "获取用户信息时出错，请重试"),
    ERR_NOT_FIND_GOODS(1008,"商品不存在"),
    ERR_AMOUNT_NOT_ENOUGH(1009,"用户乐豆不足"),
    ERR_GOODS_NOT_ENOUGH(1010,"兑换物品库存不足"),
    ERR_INVALID_USER(1011,"用户信息校验失败"),
    ERR_NOT_GOODS_CHANGE_USER(1012,"您只能查看自己兑换的卡密"),
    ERR_BET_AMOUNT_ERROR(1013,"投注乐豆不能小于10"),
    ERR_AMOUNT_LACK(1014,"用户乐豆余额不足"),
    ERR_THIRD_PAY_SYSTEM_BUSY(1015, "第三方充值平台繁忙，请稍后重试"),
    ERR_INVALID_NOTIFY(1016, "无效的支付通知"),
    ERR_INVALID_NOTIFY_SIGN(1017, "无效的支付通知签名"),
    ERR_NEW_USER_AWARD(1018, "您未关注或者已经领取过新人奖励"),
    ERR_ORDER_NOT_FOUND(1019,"投注订单不存在"),
    ERR_BET_NOT_WINNING(1020,"该投注订单未中奖"),
    ERR_ALREADY_GRANT_PRIZE(1021,"该订单已经领取过奖励");

    // ===========================================================
    // Fields
    // ===========================================================
    private int    mCode;
    private String mMsg;

    // ===========================================================
    // Constructors
    // ===========================================================
    Code(int pCode, String pMsg) {
        this.mCode = pCode;
        this.mMsg = pMsg;
    }

    // ===========================================================
    // Methods
    // ===========================================================
    public static Code getError(int pErrorCode) {
        for (Code code : Code.values()) {
            if (code.getCode() == pErrorCode) {
                return code;
            }
        }
        return ERR_DEFAULT;
    }

    public int getCode() {
        return this.mCode;
    }

    public String getMessage() {
        return this.mMsg;
    }
}
